#include "InvokeMode.h"
#include "InvokeInstruction.h"
#include "UserInterfaceException.h"

std::shared_ptr<MyLogger> InvokeMode::logger;

void InvokeMode::SetLogger(std::shared_ptr<MyLogger> &logger)
{
    InvokeMode::logger = logger;
}

void InvokeMode::Execute(std::vector<std::string> &args)
{
    if (args.size() == 0) {
        throw BlankInput();
    }
    std::string opt = args[0];
    args.erase(args.begin());
    if (InvokeInstruction::invokeInstMap.find(opt) == InvokeInstruction::invokeInstMap.end()) {
        throw UnfoundInstruction("option not found\n");
    }
    InvokeInstruction::invokeInstMap.at(opt)->Execute(args);
}
